import sqlite3

def Login(dbpath):
    #get the db user information
    conn=sqlite3.connect(dbpath)
    c=conn.cursor()
    
    name=input('Login,Input your name:')
    password=input('login,Input your password:')
    c.execute("SELECT * FROM users WHERE name=?",[name])
    users=c.fetchall()
    if users==[]:
        print('%s is not exist,please check your name.\n'%name)
        return 0,0
            
    else:
        users_password=users[0][2]
        if password==users_password:
            print('Welcome to %s\'s salary notebook!\n'%name)
            return conn,c
        else:
            print('Password error.\n')
            return 0,0
            
    #c.execute("SELECT * FROM users")
    #print(c.fetchall()) #show users
    
    c.close()
    conn.close()

if __name__=="__main__":
    dbpath='test.db'
    conn,cursor=Login(dbpath)
